home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Resources / Online / Term / Extras / Source / term-source.lha / NewMarker.c < prev    next >
C/C++ Source or Header  |  1996-10-20  |  21KB  |  829 lines

  1. /*
  2. **    NewMarker.c
  3. **
  4. **    Text block marker routines
  5. **
  6. **    Copyright © 1990-1996 by Olaf `Olsen' Barthel
  7. **        All Rights Reserved
  8. **
  9. **    :ts=4
  10. */
  11.  
  12. #ifndef _GLOBAL_H
  13. #include "Global.h"
  14. #endif
  15.  
  16. /****************************************************************************/
  17.  
  18. /*#define DB(x)    x*/
  19. #define DB(x)    ;
  20.  
  21. /****************************************************************************/
  22.  
  23. STATIC VOID
  24. UpdateLineData(MarkerContext *Context)
  25. {
  26.     Context->FirstFullLine    = Context->FirstPartialLine + 1;
  27.     Context->LastFullLine    = Context->LastPartialLine - 1;
  28.  
  29.     if(Context->FirstFullLine > Context->LastFullLine)
  30.         Context->FirstFullLine = Context->LastFullLine = -1;
  31.  
  32.     if(Context->FirstPartialLeft == 0 && Context->FirstPartialRight == Context->NumColumns - 1)
  33.     {
  34.         Context->FirstFullLine = Context->FirstPartialLine;
  35.  
  36.         if(Context->LastFullLine == -1)
  37.             Context->LastFullLine = Context->FirstFullLine;
  38.     }
  39.  
  40.     if(Context->LastPartialLeft == 0 && Context->LastPartialRight == Context->NumColumns - 1)
  41.         Context->LastFullLine = Context->LastPartialLine;
  42.  
  43.     DB(kprintf("\033[3HFirstP: %4ld <%4ld,%4ld>\033[K\n",Context->FirstPartialLine,Context->FirstPartialLeft,Context->FirstPartialRight));
  44.     DB(kprintf("FirstF: %4ld\033[K\n",Context->FirstFullLine));
  45.     DB(kprintf(" LastP: %4ld <%4ld,%4ld>\033[K\n",Context->LastPartialLine,Context->LastPartialLeft,Context->LastPartialRight));
  46.     DB(kprintf(" LastF: %4ld\033[K\n",Context->LastFullLine));
  47.     DB(kprintf("   Dir: %4ld\033[K\n",Context->Direction));
  48. }
  49.  
  50. STATIC VOID
  51. UnhighlightAll(MarkerContext *Context)
  52. {
  53.         /* Clear the selection in the first line. */
  54.  
  55.     if(Context->FirstPartialLine != Context->FirstFullLine)
  56.         Context->Unhighlight(Context,Context->FirstPartialLine,Context->FirstPartialLeft,Context->FirstPartialRight);
  57.  
  58.         /* Clear the text in between the first and the last line. */
  59.  
  60.     if(Context->FirstFullLine != -1 && Context->LastFullLine != -1)
  61.     {
  62.         LONG i;
  63.  
  64.         for(i = Context->FirstFullLine ; i <= Context->LastFullLine ; i++)
  65.             Context->Unhighlight(Context,i,0,Context->NumColumns - 1);
  66.     }
  67.  
  68.         /* Clear the selection in the last line. */
  69.  
  70.     if(Context->LastPartialLine != Context->LastFullLine && Context->LastPartialLine != Context->FirstPartialLine)
  71.         Context->Unhighlight(Context,Context->LastPartialLine,Context->LastPartialLeft,Context->LastPartialRight);
  72. }
  73.  
  74. STATIC VOID
  75. HighlightAll(MarkerContext *Context)
  76. {
  77.         /* Highlight the first line. */
  78.  
  79.     if(Context->FirstPartialLine != Context->FirstFullLine)
  80.         Context->Highlight(Context,Context->FirstPartialLine,Context->FirstPartialLeft,Context->FirstPartialRight);
  81.  
  82.         /* Highlight the text in between the first and the last line. */
  83.  
  84.     if(Context->FirstFullLine != -1 && Context->LastFullLine != -1)
  85.     {
  86.         LONG i;
  87.  
  88.         for(i = Context->FirstFullLine ; i <= Context->LastFullLine ; i++)
  89.             Context->Highlight(Context,i,0,Context->NumColumns - 1);
  90.     }
  91.  
  92.         /* Highlight the last line. */
  93.  
  94.     if(Context->LastPartialLine != Context->LastFullLine && Context->LastPartialLine != Context->FirstPartialLine)
  95.         Context->Highlight(Context,Context->LastPartialLine,Context->LastPartialLeft,Context->LastPartialRight);
  96. }
  97.  
  98. struct MarkerContext *
  99. CreateMarkerContext(
  100.     MARKER_AskPosition            AskPosition,
  101.     MARKER_Scroll                Scroll,
  102.     MARKER_Highlight            Highlight,
  103.     MARKER_Highlight            Unhighlight,
  104.     MARKER_TransferStartStop    TransferStartStop,
  105.     MARKER_Transfer                Transfer,
  106.     MARKER_Put                    Put,
  107.     MARKER_Put                    PutLine,
  108.     MARKER_PickWord                PickWord)
  109. {
  110.     MarkerContext *Context;
  111.  
  112.     if(Context = (MarkerContext *)AllocVecPooled(sizeof(MarkerContext),MEMF_ANY|MEMF_CLEAR))
  113.     {
  114.         Context->AskPosition        = AskPosition;
  115.         Context->Scroll                = Scroll;
  116.         Context->Highlight            = Highlight;
  117.         Context->Unhighlight        = Unhighlight;
  118.         Context->TransferStartStop    = TransferStartStop;
  119.         Context->Transfer            = Transfer;
  120.         Context->Put                = Put;
  121.         Context->PutLine            = PutLine;
  122.         Context->PickWord            = PickWord;
  123.  
  124.         ResetMarkerContext(Context);
  125.     }
  126.  
  127.     return(Context);
  128. }
  129.  
  130. VOID
  131. ResetMarkerContext(struct MarkerContext *Context)
  132. {
  133.     Context->FirstVisibleLine    = -1;
  134.     Context->NumVisibleLines    = -1;
  135.     Context->NumLines            = -1;
  136.  
  137.     Context->FirstVisibleColumn    = -1;
  138.     Context->NumVisibleColumns    = -1;
  139.     Context->NumColumns            = -1;
  140.  
  141.     Context->AnchorColumn        = -1;
  142.     Context->AnchorLine            = -1;
  143.  
  144.     Context->CurrentColumn        = -1;
  145.     Context->CurrentLine        = -1;
  146.  
  147.     Context->FirstFullLine        = -1;
  148.     Context->LastFullLine        = -1;
  149.  
  150.     Context->FirstPartialLine    = -1;
  151.     Context->FirstPartialLeft    = -1;
  152.     Context->FirstPartialRight    = -1;
  153.  
  154.     Context->LastPartialLine    = -1;
  155.     Context->LastPartialLeft    = -1;
  156.     Context->LastPartialRight    = -1;
  157.  
  158. }
  159.  
  160. VOID
  161. UpMarker(struct MarkerContext *Context)
  162. {
  163.     if(Context->CurrentLine != -1)
  164.     {
  165.         UnhighlightAll(Context);
  166.  
  167.         ResetMarkerContext(Context);
  168.     }
  169. }
  170.  
  171. VOID
  172. DownMarker(struct MarkerContext *Context,
  173.     LONG FirstVisibleLine,
  174.     LONG NumVisibleLines,
  175.     LONG NumLines,
  176.  
  177.     LONG FirstVisibleColumn,
  178.     LONG NumVisibleColumns,
  179.     LONG NumColumns)
  180. {
  181.     LONG Left,Top;
  182.  
  183.     Context->FirstVisibleLine    = FirstVisibleLine;
  184.     Context->NumVisibleLines    = NumVisibleLines;
  185.     Context->NumLines            = NumLines;
  186.  
  187.     Context->FirstVisibleColumn    = FirstVisibleColumn;
  188.     Context->NumVisibleColumns    = NumVisibleColumns;
  189.     Context->NumColumns            = NumColumns;
  190.  
  191.     Context->AskPosition(Context,&Left,&Top,MARKERASK_Clipped);
  192.  
  193.     Context->AnchorColumn        = Left    + Context->FirstVisibleColumn;
  194.     Context->AnchorLine            = Top    + Context->FirstVisibleLine;
  195.  
  196.     Context->CurrentColumn        = Context->AnchorColumn;
  197.     Context->CurrentLine        = Context->AnchorLine;
  198.  
  199.     Context->FirstPartialLine    = Context->CurrentLine;
  200.     Context->FirstPartialLeft    = Context->CurrentColumn;
  201.     Context->FirstPartialRight    = Context->CurrentColumn;
  202.  
  203.     Context->LastPartialLine    = Context->FirstPartialLine;
  204.     Context->LastPartialLeft    = Context->FirstPartialLeft;
  205.     Context->LastPartialRight    = Context->FirstPartialRight;
  206.  
  207.     UpdateLineData(Context);
  208.     HighlightAll(Context);
  209. }
  210.  
  211. VOID
  212. MoveMouseMarker(struct MarkerContext *Context)
  213. {
  214.     LONG ScrollLeft,ScrollTop;
  215.     LONG Left,Top,i;
  216.  
  217.         /* Get the current mouse position. The dimensions are in
  218.          * local coordinates and need to be translated into
  219.          * global coordinates. Note that the coordinates may be
  220.          * larger or smaller than the currently visible portion
  221.          * of the display.
  222.          */
  223.  
  224.     Context->AskPosition(Context,&Left,&Top,MARKERASK_Scroll);
  225.  
  226.     ScrollLeft = ScrollTop = 0;
  227.  
  228.         /* If the horizontal position is negative, scroll left one column. */
  229.  
  230.     if(Left < 0)
  231.     {
  232.             /* Check if there is another column to scroll into view. */
  233.  
  234.         if(Context->FirstVisibleColumn > 0)
  235.         {
  236.             ScrollLeft = -1;
  237.  
  238.             Context->FirstVisibleColumn--;
  239.         }
  240.  
  241.             /* Normalize the position. */
  242.  
  243.         Left = 0;
  244.     }
  245.     else
  246.     {
  247.             /* If the horizontal position is larger than the visible region,
  248.              * scroll right one column.
  249.              */
  250.  
  251.         if(Left >= Context->NumVisibleColumns)
  252.         {
  253.                 /* Check if there is another column to scroll into view. */
  254.  
  255.             if(Context->FirstVisibleColumn + Context->NumVisibleColumns < Context->NumColumns)
  256.             {
  257.                 ScrollLeft = 1;
  258.  
  259.                 Context->FirstVisibleColumn++;
  260.             }
  261.  
  262.                 /* Normalize the position. */
  263.  
  264.             Left = Context->NumVisibleColumns - 1;
  265.         }
  266.     }
  267.  
  268.         /* If the vertical position is negative, scroll up one line. */
  269.  
  270.     if(Top < 0)
  271.     {
  272.             /* Check if there is another line to scroll into view. */
  273.  
  274.         if(Context->FirstVisibleLine > 0)
  275.         {
  276.             ScrollTop = -1;
  277.  
  278.             Context->FirstVisibleLine--;
  279.         }
  280.  
  281.             /* Normalize the position. */
  282.  
  283.         Top = 0;
  284.     }
  285.     else
  286.     {
  287.             /* If the vertical position is larger than the visible region,
  288.              * scroll down one line.
  289.              */
  290.  
  291.         if(Top >= Context->NumVisibleLines)
  292.         {
  293.                 /* Check if there is another line to scroll into view. */
  294.  
  295.             if(Context->FirstVisibleLine + Context->NumVisibleLines < Context->NumLines)
  296.             {
  297.                 ScrollTop = 1;
  298.  
  299.                 Context->FirstVisibleLine++;
  300.             }
  301.  
  302.                 /* Normalize the position. */
  303.  
  304.             Top = Context->NumVisibleLines - 1;
  305.         }
  306.     }
  307.  
  308.         /* Scroll the display if we have to. */
  309.  
  310.     if(ScrollLeft != 0 || ScrollTop != 0)
  311.         Context->Scroll(Context,ScrollLeft,ScrollTop);
  312.  
  313.         /* Translate into global coordinates. */
  314.  
  315.     Left    += Context->FirstVisibleColumn;
  316.     Top        += Context->FirstVisibleLine;
  317.  
  318.         /* Check if the mouse did move at all. */
  319.  
  320.     if(Left != Context->CurrentColumn || Top != Context->CurrentLine)
  321.     {
  322.         LONG NewDir;
  323.  
  324.         if(Top < Context->AnchorLine)
  325.             NewDir = -1;
  326.         else if (Top > Context->AnchorLine)
  327.             NewDir =  1;
  328.         else
  329.         {
  330.             if(Left < Context->AnchorColumn)
  331.                 NewDir = -1;
  332.             else
  333.                 NewDir =  1;
  334.         }
  335.  
  336.         if(Context->Direction == 0)
  337.             Context->Direction = NewDir;
  338.  
  339.         DB(kprintf("\033[9HTop <%4ld> Last <%4ld,%4ld> Anchor <%4ld,%4ld> Dir <%2ld> NewDir <%2ld>\033[K\n",Top,Context->CurrentLine,Context->CurrentColumn,Context->AnchorLine,Context->AnchorColumn,Context->Direction,NewDir));
  340.  
  341.             /* Check for "crossover", i.e. if the mouse moved to the other
  342.              * side of the marker anchor.
  343.              */
  344.  
  345.         if(Context->Direction != NewDir)
  346.         {
  347.                 /* Unhighlight the highlighted lines. */
  348.  
  349.             UnhighlightAll(Context);
  350.  
  351.                 /* Now check where the mouse moved to in relation to the anchor. */
  352.  
  353.             if(Top < Context->AnchorLine)
  354.             {
  355.                 DB(kprintf("\033[8H(1)\033[K\n"));
  356.  
  357.                     /* Mouse is above the marker anchor. */
  358.  
  359.                 Context->Direction = -1;
  360.  
  361.                 Context->FirstPartialLine    = Top;
  362.                 Context->FirstPartialLeft    = Left;
  363.                 Context->FirstPartialRight    = Context->NumColumns - 1;
  364.  
  365.                 Context->LastPartialLine    = Context->AnchorLine;
  366.                 Context->LastPartialLeft    = 0;
  367.                 Context->LastPartialRight    = MAX(0,Context->AnchorColumn - 1);
  368.             }
  369.             else if (Top > Context->AnchorLine)
  370.             {
  371.                 DB(kprintf("\033[8H(2)\033[K\n"));
  372.  
  373.                     /* Mouse is below the marker anchor. */
  374.  
  375.                 Context->Direction = 1;
  376.  
  377.                 Context->FirstPartialLine    = Context->AnchorLine;
  378.                 Context->FirstPartialLeft    = Context->AnchorColumn;
  379.                 Context->FirstPartialRight    = Context->NumColumns - 1;
  380.  
  381.                 Context->LastPartialLine    = Top;
  382.                 Context->LastPartialLeft    = 0;
  383.                 Context->LastPartialRight    = Left;
  384.             }
  385.             else
  386.             {
  387.                 DB(kprintf("\033[8H(3)\033[K\n"));
  388.  
  389.                     /* Mouse is in the same line as the marker anchor. */
  390.  
  391.                 if(Left < Context->AnchorColumn)
  392.                 {
  393.                         /* Mouse is left of the marker anchor. */
  394.  
  395.                     Context->Direction = -1;
  396.  
  397.                     Context->FirstPartialLeft    = Left;
  398.                     Context->FirstPartialRight    = MAX(Left,Context->AnchorColumn - 1);
  399.                 }
  400.                 else
  401.                 {
  402.                         /* Mouse is right of the marker anchor. */
  403.  
  404.                     Context->Direction = 1;
  405.  
  406.                     Context->FirstPartialLeft    = Context->AnchorColumn;
  407.                     Context->FirstPartialRight    = Left;
  408.                 }
  409.  
  410.                 Context->FirstPartialLine    = Context->AnchorLine;
  411.                 Context->LastPartialLine    = Context->FirstPartialLine;
  412.                 Context->LastPartialLeft    = Context->FirstPartialLeft;
  413.                 Context->LastPartialRight    = Context->FirstPartialRight;
  414.             }
  415.  
  416.             UpdateLineData(Context);
  417.             HighlightAll(Context);
  418.         }
  419.         else
  420.         {
  421.             DB(kprintf("\033[8H\033[K\n"));
  422.  
  423.                 /* Check which line the mouse moved into, with respect to its previous placement. */
  424.  
  425.             if(Top == Context->CurrentLine)
  426.             {
  427.                     /* Mouse is still on the same line. */
  428.  
  429.                 if(Context->Direction > 0)
  430.                 {
  431.                     if(Left < Context->CurrentColumn)
  432.                     {
  433.                             /* Mouse moved left (<-). */
  434.  
  435.                         Context->Unhighlight(Context,Context->CurrentLine,Left + 1,Context->CurrentColumn);
  436.                     }
  437.                     else
  438.                     {
  439.                             /* Mouse moved right (->). */
  440.  
  441.                         Context->Highlight(Context,Context->CurrentLine,Context->CurrentColumn + 1,Left);
  442.                     }
  443.  
  444.                     Context->LastPartialRight = Left;
  445.  
  446.                     if(Context->FirstPartialLine == Context->LastPartialLine)
  447.                         Context->FirstPartialRight = Left;
  448.                 }
  449.                 else
  450.                 {
  451.                     if(Left < Context->CurrentColumn)
  452.                     {
  453.                             /* Mouse moved left (<-). */
  454.  
  455.                         Context->Highlight(Context,Context->CurrentLine,Left,Context->CurrentColumn - 1);
  456.                     }
  457.                     else
  458.                     {
  459.                             /* Mouse moved right (->). */
  460.  
  461.                         Context->Unhighlight(Context,Context->CurrentLine,Context->CurrentColumn,Left - 1);
  462.                     }
  463.  
  464.                     Context->FirstPartialLeft = Left;
  465.  
  466.                     if(Context->FirstPartialLine == Context->LastPartialLine)
  467.                         Context->LastPartialLeft = Left;
  468.                 }
  469.             }
  470.             else if(Top < Context->CurrentLine)
  471.             {
  472.                     /* Mouse is above the previously selected line. */
  473.  
  474.                 if(Context->Direction > 0)
  475.                 {
  476.                         /* Clear the text selected in the lines below the mouse position. */
  477.  
  478.                     if(Context->LastPartialLine != Context->LastFullLine)
  479.                         Context->Unhighlight(Context,Context->LastPartialLine,0,Context->LastPartialRight);
  480.  
  481.                     if(Context->LastFullLine != -1)
  482.                     {
  483.                         for(i = Context->LastFullLine ; i > Top ; i--)
  484.                             Context->Unhighlight(Context,i,0,Context->NumColumns - 1);
  485.                     }
  486.  
  487.                         /* Clear the text selected in the new mouse line, but only the text following the new mouse position. */
  488.  
  489.                     Context->Unhighlight(Context,Top,Left + 1,Context->NumColumns - 1);
  490.  
  491.                     Context->LastPartialLine    = Top;
  492.                     Context->LastPartialRight    = Left;
  493.  
  494.                     if(Context->LastPartialLine == Context->FirstPartialLine)
  495.                         Context->LastPartialLeft = Context->FirstPartialLeft;
  496.                     else
  497.                         Context->LastPartialLeft = 0;
  498.  
  499.                     if(Context->FirstPartialLine == Context->LastPartialLine)
  500.                     {
  501.                         Context->FirstPartialLeft    = Context->LastPartialLeft;
  502.                         Context->FirstPartialRight    = Context->LastPartialRight;
  503.                     }
  504.                 }
  505.                 else
  506.                 {
  507.                         /* Fill the first partial line completely. */
  508.  
  509.                     if(Context->FirstPartialLine != Context->FirstFullLine)
  510.                     {
  511.                         Context->Highlight(Context,Context->FirstPartialLine,0,Context->FirstPartialLeft - 1);
  512.  
  513.                         Context->FirstPartialLeft = 0;
  514.  
  515.                         if(Context->FirstPartialLine == Context->LastPartialLine)
  516.                             Context->LastPartialLeft = Context->FirstPartialLeft;
  517.                     }
  518.  
  519.                         /* Mark the text selected in the lines below the mouse pointer. */
  520.  
  521.                     for(i = Top + 1 ; i < Context->FirstPartialLine ; i++)
  522.                         Context->Highlight(Context,i,0,Context->NumColumns - 1);
  523.  
  524.                     Context->Highlight(Context,Top,Left,Context->NumColumns - 1);
  525.  
  526.                     Context->FirstPartialLine    = Top;
  527.                     Context->FirstPartialLeft    = Left;
  528.                     Context->FirstPartialRight    = Context->NumColumns - 1;
  529.  
  530.                     if(Context->FirstPartialLine == Context->LastPartialLine)
  531.                     {
  532.                         Context->LastPartialLeft    = Context->FirstPartialLeft;
  533.                         Context->LastPartialRight    = Context->FirstPartialRight;
  534.                     }
  535.                 }
  536.             }
  537.             else
  538.             {
  539.                     /* The mouse is below the last line. */
  540.  
  541.                 if(Context->Direction > 0)
  542.                 {
  543.                         /* Fill the last partial line completely. */
  544.  
  545.                     if(Context->LastPartialLine != Context->LastFullLine)
  546.                     {
  547.                         Context->Highlight(Context,Context->LastPartialLine,Context->LastPartialRight + 1,Context->NumColumns - 1);
  548.  
  549.                         Context->LastPartialRight = Context->NumColumns - 1;
  550.  
  551.                         if(Context->LastPartialLine == Context->FirstPartialLine)
  552.                             Context->FirstPartialRight = Context->NumColumns - 1;
  553.                     }
  554.  
  555.                         /* Fill the lines above the mouse pointer. */
  556.  
  557.                     for(i = Context->LastPartialLine + 1 ; i < Top ; i++)
  558.                         Context->Highlight(Context,i,0,Context->NumColumns - 1);
  559.  
  560.                     Context->Highlight(Context,Top,0,Left);
  561.  
  562.                     Context->LastPartialLine    = Top;
  563.                     Context->LastPartialLeft    = 0;
  564.                     Context->LastPartialRight    = Left;
  565.  
  566.                     if(Context->FirstPartialLine == Context->LastPartialLine)
  567.                     {
  568.                         Context->FirstPartialLeft    = Context->LastPartialLeft;
  569.                         Context->FirstPartialRight    = Context->LastPartialRight;
  570.                     }
  571.                 }
  572.                 else
  573.                 {
  574.                         /* Clear the first selected line completely. */
  575.  
  576.                     if(Context->FirstPartialLine != Context->FirstFullLine)
  577.                         Context->Unhighlight(Context,Context->FirstPartialLine,Context->FirstPartialLeft,Context->NumColumns - 1);
  578.  
  579.                     if(Context->FirstFullLine != -1)
  580.                     {
  581.                         for(i = Context->FirstFullLine ; i < Top ; i++)
  582.                             Context->Unhighlight(Context,i,0,Context->NumColumns - 1);
  583.                     }
  584.  
  585.                     Context->Unhighlight(Context,Top,0,Left - 1);
  586.  
  587.                     Context->FirstPartialLine    = Top;
  588.                     Context->FirstPartialLeft    = Left;
  589.  
  590.                     if(Context->FirstPartialLine == Context->LastPartialLine)
  591.                         Context->FirstPartialRight = Context->LastPartialRight;
  592.                     else
  593.                         Context->FirstPartialRight = Context->NumColumns - 1;
  594.  
  595.                     if(Context->FirstPartialLine == Context->LastPartialLine)
  596.                     {
  597.                         Context->LastPartialLeft    = Context->FirstPartialLeft;
  598.                         Context->LastPartialRight    = Context->FirstPartialRight;
  599.                     }
  600.                 }
  601.             }
  602.  
  603.             UpdateLineData(Context);
  604.         }
  605.  
  606.         Context->CurrentColumn    = Left;
  607.         Context->CurrentLine    = Top;
  608.     }
  609. }
  610.  
  611. BOOL
  612. CheckMarkerHighlighting(struct MarkerContext *Context,LONG Line,LONG *Left,LONG *Right)
  613. {
  614.     if(Line < Context->FirstPartialLine || Line > Context->LastPartialLine)
  615.         return(FALSE);
  616.     else
  617.     {
  618.         if(Line == Context->FirstPartialLine)
  619.         {
  620.             *Left    = Context->FirstPartialLeft;
  621.             *Right    = Context->FirstPartialRight;
  622.         }
  623.         else if (Line == Context->LastPartialLine)
  624.         {
  625.             *Left    = Context->LastPartialLeft;
  626.             *Right    = Context->LastPartialRight;
  627.         }
  628.         else
  629.         {
  630.             *Left    = 0;
  631.             *Right    = Context->NumColumns - 1;
  632.         }
  633.  
  634.         return(TRUE);
  635.     }
  636. }
  637.  
  638. VOID
  639. TransferMarker(struct MarkerContext *Context,ULONG Qualifier)
  640. {
  641.     if(Context->FirstPartialLine != -1 && Context->LastPartialLine != -1)
  642.     {
  643.         APTR UserData;
  644.  
  645.         if(UserData = Context->TransferStartStop(Context,NULL,Qualifier))
  646.         {
  647.             if(Context->FirstPartialLine == Context->LastPartialLine)
  648.                 Context->Transfer(Context,Context->FirstPartialLine,Context->FirstPartialLeft,Context->FirstPartialRight,Context->Put,UserData);
  649.             else
  650.             {
  651.                 BOOL Ok;
  652.                 LONG i;
  653.  
  654.                 for(i = Context->FirstPartialLine ; i <= Context->LastPartialLine ; i++)
  655.                 {
  656.                     if(i == Context->FirstPartialLine)
  657.                         Ok = Context->Transfer(Context,i,Context->FirstPartialLeft,Context->FirstPartialRight,Context->PutLine,UserData);
  658.                     else if (i == Context->LastPartialLine)
  659.                     {
  660.                         if(Context->LastPartialLeft == 0 && Context->LastPartialRight == Context->NumColumns - 1)
  661.                             Ok = Context->Transfer(Context,i,Context->LastPartialLeft,Context->LastPartialRight,Context->PutLine,UserData);
  662.                         else
  663.                             Ok = Context->Transfer(Context,i,Context->LastPartialLeft,Context->LastPartialRight,Context->Put,UserData);
  664.                     }
  665.                     else
  666.                         Ok = Context->Transfer(Context,i,0,Context->NumColumns - 1,Context->PutLine,UserData);
  667.  
  668.                     if(!Ok)
  669.                         break;
  670.                 }
  671.             }
  672.  
  673.             Context->TransferStartStop(Context,UserData,NULL);
  674.         }
  675.     }
  676. }
  677.  
  678. BOOL
  679. SetWordMarker(
  680.     struct MarkerContext *Context,
  681.     LONG FirstVisibleLine,
  682.     LONG NumVisibleLines,
  683.     LONG NumLines,
  684.  
  685.     LONG FirstVisibleColumn,
  686.     LONG NumVisibleColumns,
  687.     LONG NumColumns)
  688. {
  689.     LONG Left,Top,WordLeft,WordRight;
  690.  
  691.     Context->FirstVisibleLine    = FirstVisibleLine;
  692.     Context->NumVisibleLines    = NumVisibleLines;
  693.     Context->NumLines            = NumLines;
  694.  
  695.     Context->FirstVisibleColumn    = FirstVisibleColumn;
  696.     Context->NumVisibleColumns    = NumVisibleColumns;
  697.     Context->NumColumns            = NumColumns;
  698.  
  699.     Context->AskPosition(Context,&Left,&Top,MARKERASK_Clipped);
  700.  
  701.     Left    += Context->FirstVisibleColumn;
  702.     Top        += Context->FirstVisibleLine;
  703.  
  704.     if(!Context->PickWord(Context,Left,Top,&WordLeft,&WordRight))
  705.         return(FALSE);
  706.     else
  707.     {
  708.         Context->AnchorColumn        = Left;
  709.         Context->AnchorLine            = Top;
  710.  
  711.         Context->CurrentColumn        = Left + WordLeft - WordRight;
  712.         Context->CurrentLine        = Top;
  713.  
  714.         Context->FirstPartialLine    = Top;
  715.         Context->FirstPartialLeft    = WordLeft;
  716.         Context->FirstPartialRight    = WordRight;
  717.  
  718.         Context->LastPartialLine    = Context->FirstPartialLine;
  719.         Context->LastPartialLeft    = Context->FirstPartialLeft;
  720.         Context->LastPartialRight    = Context->FirstPartialRight;
  721.  
  722.         Context->Direction            = 1;
  723.  
  724.         UpdateLineData(Context);
  725.         HighlightAll(Context);
  726.  
  727.         return(TRUE);
  728.     }
  729. }
  730.  
  731. VOID
  732. SetMarker(
  733.     struct MarkerContext *Context,
  734.     LONG FirstVisibleLine,
  735.     LONG NumVisibleLines,
  736.     LONG NumLines,
  737.  
  738.     LONG FirstVisibleColumn,
  739.     LONG NumVisibleColumns,
  740.     LONG NumColumns,
  741.  
  742.     LONG Line,
  743.     LONG WordLeft,
  744.     LONG WordRight)
  745. {
  746.     Context->FirstVisibleLine    = FirstVisibleLine;
  747.     Context->NumVisibleLines    = NumVisibleLines;
  748.     Context->NumLines            = NumLines;
  749.  
  750.     Context->FirstVisibleColumn    = FirstVisibleColumn;
  751.     Context->NumVisibleColumns    = NumVisibleColumns;
  752.     Context->NumColumns            = NumColumns;
  753.  
  754.     Context->AnchorColumn        = WordLeft;
  755.     Context->AnchorLine            = Line;
  756.  
  757.     Context->CurrentColumn        = WordRight;
  758.     Context->CurrentLine        = Line;
  759.  
  760.     Context->FirstPartialLine    = Line;
  761.     Context->FirstPartialLeft    = WordLeft;
  762.     Context->FirstPartialRight    = WordRight;
  763.  
  764.     Context->LastPartialLine    = Context->FirstPartialLine;
  765.     Context->LastPartialLeft    = Context->FirstPartialLeft;
  766.     Context->LastPartialRight    = Context->FirstPartialRight;
  767.  
  768.     Context->Direction            = 1;
  769.  
  770.     UpdateLineData(Context);
  771.     HighlightAll(Context);
  772. }
  773.  
  774. VOID
  775. SelectAllMarker(
  776.     struct MarkerContext *Context,
  777.     LONG FirstVisibleLine,
  778.     LONG NumVisibleLines,
  779.     LONG NumLines,
  780.  
  781.     LONG FirstVisibleColumn,
  782.     LONG NumVisibleColumns,
  783.     LONG NumColumns,
  784.  
  785.     LONG FirstLeft,
  786.     LONG FirstLine,
  787.     LONG LastRight,
  788.     LONG LastLine)
  789. {
  790.     Context->FirstVisibleLine    = FirstVisibleLine;
  791.     Context->NumVisibleLines    = NumVisibleLines;
  792.     Context->NumLines            = NumLines;
  793.  
  794.     Context->FirstVisibleColumn    = FirstVisibleColumn;
  795.     Context->NumVisibleColumns    = NumVisibleColumns;
  796.     Context->NumColumns            = NumColumns;
  797.  
  798.     Context->AnchorColumn        = FirstLeft;
  799.     Context->AnchorLine            = FirstLine;
  800.  
  801.     Context->CurrentColumn        = LastRight;
  802.     Context->CurrentLine        = LastLine;
  803.  
  804.     Context->FirstPartialLine    = FirstLine;
  805.     Context->FirstPartialLeft    = FirstLeft;
  806.     Context->FirstPartialRight    = NumColumns - 1;
  807.  
  808.     Context->LastPartialLine    = LastLine;
  809.     Context->LastPartialLeft    = 0;
  810.     Context->LastPartialRight    = LastRight;
  811.  
  812.     Context->Direction            = 1;
  813.  
  814.     UpdateLineData(Context);
  815.     HighlightAll(Context);
  816. }
  817.  
  818. BOOL
  819. CheckMarker(struct MarkerContext *Context)
  820. {
  821.     if(Context)
  822.     {
  823.         if(Context->FirstPartialLine != -1 && Context->LastPartialLine != -1)
  824.             return(TRUE);
  825.     }
  826.  
  827.     return(FALSE);
  828. }
  829.